<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>lexicographical_compare</title>
<link rel="stylesheet" href="../../../../../../../../doc/html/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="../../../../index.html" title="Chapter&#160;1.&#160;Range 2.0">
<link rel="up" href="../non_mutating.html" title="Non-mutating algorithms">
<link rel="prev" href="find_if.html" title="find_if">
<link rel="next" href="lower_bound.html" title="lower_bound">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="find_if.html"><img src="../../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../non_mutating.html"><img src="../../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="lower_bound.html"><img src="../../../../../../../../doc/html/images/next.png" alt="Next"></a>
</div>
<div class="section" title="lexicographical_compare">
<div class="titlepage"><div><div><h5 class="title">
<a name="range.reference.algorithms.non_mutating.lexicographical_compare"></a><a class="link" href="lexicographical_compare.html" title="lexicographical_compare">
          lexicographical_compare</a>
</h5></div></div></div>
<a name="range.reference.algorithms.non_mutating.lexicographical_compare.prototype"></a><h6>
<a name="id625368"></a>
            <a class="link" href="lexicographical_compare.html#range.reference.algorithms.non_mutating.lexicographical_compare.prototype">Prototype</a>
          </h6>
<p>

</p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
    <span class="keyword">class</span> <span class="identifier">SinglePassRange1</span><span class="special">,</span>
    <span class="keyword">class</span> <span class="identifier">SinglePassRange2</span>
    <span class="special">&gt;</span>
<span class="keyword">bool</span> <span class="identifier">lexicographical_compare</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">SinglePassRange1</span><span class="special">&amp;</span> <span class="identifier">rng1</span><span class="special">,</span>
                             <span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&amp;</span> <span class="identifier">rng2</span><span class="special">);</span>

<span class="keyword">template</span><span class="special">&lt;</span>
    <span class="keyword">class</span> <span class="identifier">SinglePassRange1</span><span class="special">,</span>
    <span class="keyword">class</span> <span class="identifier">SinglePassRange2</span><span class="special">,</span>
    <span class="keyword">class</span> <span class="identifier">BinaryPredicate</span>
    <span class="special">&gt;</span>
<span class="keyword">bool</span> <span class="identifier">lexicographical_compare</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">SinglePassRange1</span><span class="special">&amp;</span> <span class="identifier">rng1</span><span class="special">,</span>
                             <span class="keyword">const</span> <span class="identifier">SinglePassRange2</span><span class="special">&amp;</span> <span class="identifier">rng2</span><span class="special">,</span>
                             <span class="identifier">BinaryPredicate</span> <span class="identifier">pred</span><span class="special">);</span>
</pre>
<p>
          </p>
<a name="range.reference.algorithms.non_mutating.lexicographical_compare.description"></a><h6>
<a name="id625649"></a>
            <a class="link" href="lexicographical_compare.html#range.reference.algorithms.non_mutating.lexicographical_compare.description">Description</a>
          </h6>
<p>
            <code class="computeroutput"><span class="identifier">lexicographical_compare</span></code>
            compares element by element <code class="computeroutput"><span class="identifier">rng1</span></code>
            against <code class="computeroutput"><span class="identifier">rng2</span></code>. If the
            element from <code class="computeroutput"><span class="identifier">rng1</span></code> is
            less than the element from <code class="computeroutput"><span class="identifier">rng2</span></code>
            then <code class="computeroutput"><span class="keyword">true</span></code> is returned. If
            the end of <code class="computeroutput"><span class="identifier">rng1</span></code> without
            reaching the end of <code class="computeroutput"><span class="identifier">rng2</span></code>
            this also causes the return value to be <code class="computeroutput"><span class="keyword">true</span></code>.
            The return value is <code class="computeroutput"><span class="keyword">false</span></code>
            in all other circumstances. The elements are compared using <code class="computeroutput"><span class="keyword">operator</span><span class="special">&lt;</span></code>
            in the non-predicate versions of <code class="computeroutput"><span class="identifier">lexicographical_compare</span></code>
            and using <code class="computeroutput"><span class="identifier">pred</span></code> in the
            predicate versions.
          </p>
<a name="range.reference.algorithms.non_mutating.lexicographical_compare.definition"></a><h6>
<a name="id625822"></a>
            <a class="link" href="lexicographical_compare.html#range.reference.algorithms.non_mutating.lexicographical_compare.definition">Definition</a>
          </h6>
<p>
            Defined in the header file <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">range</span><span class="special">/</span><span class="identifier">algorithm</span><span class="special">/</span><span class="identifier">lexicographical_compare</span><span class="special">.</span><span class="identifier">hpp</span></code>
          </p>
<a name="range.reference.algorithms.non_mutating.lexicographical_compare.requirements"></a><h6>
<a name="id625894"></a>
            <a class="link" href="lexicographical_compare.html#range.reference.algorithms.non_mutating.lexicographical_compare.requirements">Requirements</a>
          </h6>
<p>
            <span class="bold"><strong>For the non-predicate versions of lexicographical_compare:</strong></span>
          </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<code class="computeroutput"><span class="identifier">SinglePassRange1</span></code> is
              a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
              Pass Range</a> Concept.
            </li>
<li class="listitem">
<code class="computeroutput"><span class="identifier">SinglePassRange2</span></code> is
              a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
              Pass Range</a> Concept.
            </li>
<li class="listitem">
<code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>'s
              value type is a model of the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>.
            </li>
<li class="listitem">
<code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>'s
              value type is a model of the <code class="computeroutput"><span class="identifier">LessThanComparableConcept</span></code>.
            </li>
<li class="listitem">
              Let <code class="computeroutput"><span class="identifier">x</span></code> be an object
              of <code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>'s
              value type. Let <code class="computeroutput"><span class="identifier">y</span></code> be
              an obect of <code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>'s
              value type. <code class="computeroutput"><span class="identifier">x</span> <span class="special">&lt;</span>
              <span class="identifier">y</span></code> must be valid. <code class="computeroutput"><span class="identifier">y</span> <span class="special">&lt;</span>
              <span class="identifier">x</span></code> must be valid.
            </li>
</ul></div>
<p>
            <span class="bold"><strong>For the predicate versions of lexicographical_compare:</strong></span>
          </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<code class="computeroutput"><span class="identifier">SinglePassRange1</span></code> is
              a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
              Pass Range</a> Concept.
            </li>
<li class="listitem">
<code class="computeroutput"><span class="identifier">SinglePassRange2</span></code> is
              a model of the <a class="link" href="../../../concepts/single_pass_range.html" title="Single Pass Range">Single
              Pass Range</a> Concept.
            </li>
<li class="listitem">
<code class="computeroutput"><span class="identifier">BinaryPredicate</span></code> is
              a model of the <code class="computeroutput"><span class="identifier">BinaryPredicateConcept</span></code>.
            </li>
<li class="listitem">
<code class="computeroutput"><span class="identifier">SinglePassRange1</span></code>'s
              value type is convertible to <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code>'s
              first argument type.
            </li>
<li class="listitem">
<code class="computeroutput"><span class="identifier">SinglePassRange2</span></code>'s
              value type is convertible to <code class="computeroutput"><span class="identifier">BinaryPredicate</span></code>'s
              second argument type.
            </li>
</ul></div>
<a name="range.reference.algorithms.non_mutating.lexicographical_compare.complexity"></a><h6>
<a name="id626250"></a>
            <a class="link" href="lexicographical_compare.html#range.reference.algorithms.non_mutating.lexicographical_compare.complexity">Complexity</a>
          </h6>
<p>
            Linear. At most <code class="computeroutput"><span class="number">2</span> <span class="special">*</span>
            <span class="identifier">min</span><span class="special">(</span><span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng1</span><span class="special">),</span> <span class="identifier">distance</span><span class="special">(</span><span class="identifier">rng2</span><span class="special">))</span></code>
            comparisons.
          </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2003 -2010 Thorsten Ottosen, Neil Groves<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="find_if.html"><img src="../../../../../../../../doc/html/images/prev.png" alt="Prev"></a><a accesskey="u" href="../non_mutating.html"><img src="../../../../../../../../doc/html/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/html/images/home.png" alt="Home"></a><a accesskey="n" href="lower_bound.html"><img src="../../../../../../../../doc/html/images/next.png" alt="Next"></a>
</div>
</body>
</html>
